CUR_DIR        =        $(shell pwd)
CC = gcc 
LD = gcc
MV=mv
EMCC=emcc

SRC_DIR=./src
SRCS = $(wildcard ./src/*.c)
OBJS = $(patsubst %c, %o, $(SRCS))

LINUX_TEST_TARGET = linux_decoder_test
INCLUDE =-I ./include
OBJ_DIR =./obj
DIST_DIR =./test-out
WASM_LIB_DIR=./wasm-libs

# -L指定库文件目录，-l指定静态库名字(去掉文件名中的lib前缀和.a后缀)

LIB = -L./linux-libs  -lavcodec -lavformat -lswscale -lavutil -lavdevice -lm  -lz 

# 开启编译warning和设置优化等级
#CFLAGS = -Wall -O2
CFLAGS = $(INCLUDE) -g -std=c99

DIST=out

.PHONY:all clean

%.o : %.c
	$(CC) -c $(CFLAGS) $< -o $@

all:  $(LINUX_TEST_TARGET) 
	echo "RUN 'source /mnt/d/dev/emsdk/wsl/emsdk/emsdk_env.sh' FIRST"

$(LINUX_TEST_TARGET): mvObjs
	$(LD)  $(OBJ_DIR )/*.o -o $(DIST_DIR )/$(LINUX_TEST_TARGET) $(LIB)

mvObjs: $(OBJS)
	$(MV) $(CUR_DIR)/$(SRC_DIR)/*.o $(CUR_DIR)/$(OBJ_DIR )/


wasm: $(OBJS)
	sh ./build_decoder_wasm.sh

clean:
	rm -f $(OBJ_DIR )/*.o $(DIST_DIR )/*

